home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / demos / fbrowser.tcl next >
Encoding:
Text File  |  1993-11-20  |  20.6 KB  |  774 lines

  1. #!/home/stone/garfield/bin/X386/epwish -f
  2. # Program: fbrowser
  3. # Tcl version: 6.6 (Tcl/Tk/XF)
  4. # Tk version: 3.1
  5. # XF version: 2.1
  6. #
  7.  
  8. # module inclusion
  9. global env
  10. global xfLoadPath
  11. if {[info exists env(XF_LOAD_PATH)]} {
  12.   if {[string first $env(XF_LOAD_PATH) /usr/local/lib/] == -1} {
  13.     set xfLoadPath $env(XF_LOAD_PATH):/usr/local/lib/
  14.   } {
  15.     set xfLoadPath /usr/local/lib/
  16.   }
  17. } {
  18.   set xfLoadPath /usr/local/lib/
  19. }
  20.  
  21. global argc
  22. global argv
  23. global tkVersion
  24. global xfLoadInfo
  25. global xfLoadPath
  26. set xfLoadInfo 0
  27. set tmpArgv ""
  28. for {set counter 0} {$counter < $argc} {incr counter 1} {
  29.   case [string tolower [lindex $argv $counter]] in {
  30.     {-xfloadpath} {
  31.       incr counter 1
  32.       set xfLoadPath "[lindex $argv $counter]:$xfLoadPath"
  33.     }
  34.     {-xfstartup} {
  35.       incr counter 1
  36.       source [lindex $argv $counter]
  37.     }
  38.     {-xfbindfile} {
  39.       incr counter 1
  40.       set env(XF_BIND_FILE) "[lindex $argv $counter]"
  41.     }
  42.     {-xfcolorfile} {
  43.       incr counter 1
  44.       set env(XF_COLOR_FILE) "[lindex $argv $counter]"
  45.     }
  46.     {-xfcursorfile} {
  47.       incr counter 1
  48.       set env(XF_CURSOR_FILE) "[lindex $argv $counter]"
  49.     }
  50.     {-xffontfile} {
  51.       incr counter 1
  52.       set env(XF_FONT_FILE) "[lindex $argv $counter]"
  53.     }
  54.     {-xfmodelmono} {
  55.       if {$tkVersion >= 3.0} {
  56.         tk colormodel . monochrome
  57.       }
  58.     }
  59.     {-xfmodelcolor} {
  60.       if {$tkVersion >= 3.0} {
  61.         tk colormodel . color
  62.       }
  63.     }
  64.     {-xfloading} {
  65.       set xfLoadInfo 1
  66.     }
  67.     {-xfnoloading} {
  68.       set xfLoadInfo 0
  69.     }
  70.     {default} {
  71.       lappend tmpArgv [lindex $argv $counter]
  72.     }
  73.   }
  74. }
  75. set argv $tmpArgv
  76. set argc [llength $tmpArgv]
  77. unset counter
  78. unset tmpArgv
  79.  
  80.  
  81. # procedure to show window .
  82. proc ShowWindow. {args} {# xf ignore me 7
  83.  
  84.   # Window manager configurations
  85.   global tkVersion
  86.   wm positionfrom . user
  87.   wm sizefrom . ""
  88.   wm geometry . 450x250
  89.   wm maxsize . 1024 900
  90.   wm minsize . 0 0
  91.   wm title . {fbrowser}
  92.  
  93.  
  94.   # build widget .frame0
  95.   frame .frame0 \
  96.     -borderwidth {2} \
  97.     -relief {raised}
  98.  
  99.   # build widget .frame0.menubutton3
  100.   menubutton .frame0.menubutton3 \
  101.     -menu {.frame0.menubutton3.m} \
  102.     -text {File}
  103.  
  104.   # build widget .frame0.menubutton3.m
  105.   menu .frame0.menubutton3.m 
  106.   .frame0.menubutton3.m add command \
  107.     -command {TkBroRefresh} \
  108.     -label {Refresh}
  109.   .frame0.menubutton3.m add command \
  110.     -command {catch "destroy ."; catch "exit 0"} \
  111.     -label {Quit}
  112.  
  113.   # pack widget .frame0
  114.   pack append .frame0 \
  115.     .frame0.menubutton3 {left frame center} 
  116.  
  117.   # build widget .frame1
  118.   frame .frame1 \
  119.     -relief {raised}
  120.  
  121.   # build widget .frame1.label4
  122.   label .frame1.label4 \
  123.     -anchor {w} \
  124.     -padx {2} \
  125.     -relief {raised} \
  126.     -text {/home/garfield/development/xf/demos}
  127.  
  128.   # build widget .frame1.label5
  129.   label .frame1.label5 \
  130.     -padx {2} \
  131.     -relief {raised} \
  132.     -text {}
  133.  
  134.   # pack widget .frame1
  135.   pack append .frame1 \
  136.     .frame1.label4 {left frame center expand fillx} \
  137.     .frame1.label5 {right frame center fillx} 
  138.  
  139.   # build widget .frame2
  140.   frame .frame2 \
  141.     -relief {raised}
  142.  
  143.   # build widget .frame2.frame
  144.   frame .frame2.frame 
  145.  
  146.   # build widget .frame2.frame.scrollbar2
  147.   scrollbar .frame2.frame.scrollbar2 \
  148.     -command {.frame2.frame.listbox1 yview} \
  149.     -relief {raised}
  150.  
  151.   # build widget .frame2.frame.scrollbar3
  152.   scrollbar .frame2.frame.scrollbar3 \
  153.     -command {.frame2.frame.listbox1 xview} \
  154.     -orient {horizontal} \
  155.     -relief {raised}
  156.  
  157.   # build widget .frame2.frame.listbox1
  158.   listbox .frame2.frame.listbox1 \
  159.     -relief {raised} \
  160.     -xscrollcommand {.frame2.frame.scrollbar3 set} \
  161.     -yscrollcommand {.frame2.frame.scrollbar2 set}
  162.   # bindings
  163.   bind .frame2.frame.listbox1 <Button-1> {TkBroOpen [%W get [%W nearest %y]]}
  164.  
  165.   # pack widget .frame2.frame
  166.   pack append .frame2.frame \
  167.     .frame2.frame.scrollbar2 {left frame center filly} \
  168.     .frame2.frame.listbox1 {top frame center expand fill} \
  169.     .frame2.frame.scrollbar3 {bottom frame center fillx} 
  170.  
  171.   # build widget .frame2.frame6
  172.   frame .frame2.frame6 
  173.  
  174.   # build widget .frame2.frame6.scrollbar2
  175.   scrollbar .frame2.frame6.scrollbar2 \
  176.     -command {.frame2.frame6.listbox1 yview} \
  177.     -relief {raised}
  178.  
  179.   # build widget .frame2.frame6.scrollbar3
  180.   scrollbar .frame2.frame6.scrollbar3 \
  181.     -command {.frame2.frame6.listbox1 xview} \
  182.     -orient {horizontal} \
  183.     -relief {raised}
  184.  
  185.   # build widget .frame2.frame6.listbox1
  186.   listbox .frame2.frame6.listbox1 \
  187.     -geometry {10x2} \
  188.     -relief {raised} \
  189.     -xscrollcommand {.frame2.frame6.scrollbar3 set} \
  190.     -yscrollcommand {.frame2.frame6.scrollbar2 set}
  191.  
  192.   # pack widget .frame2.frame6
  193.   pack append .frame2.frame6 \
  194.     .frame2.frame6.scrollbar2 {left frame center filly} \
  195.     .frame2.frame6.listbox1 {top frame center expand fill} \
  196.     .frame2.frame6.scrollbar3 {bottom frame center fillx} 
  197.  
  198.   # pack widget .frame2
  199.   pack append .frame2 \
  200.     .frame2.frame {left frame center filly} \
  201.     .frame2.frame6 {left frame center expand fill} 
  202.  
  203.   # pack widget .
  204.   pack append . \
  205.     .frame0 {top frame center fillx} \
  206.     .frame1 {top frame center fillx} \
  207.     .frame2 {top frame center expand fill} 
  208.  
  209.   if {"[info procs XFEdit]" != ""} {
  210.     XFEditSetShowWindows
  211.     XFMiscBindWidgetTree .xfEdit
  212.   }
  213.  
  214.   .frame2.frame.listbox1 insert end {.}
  215.   .frame2.frame.listbox1 insert end {..}
  216.   .frame2.frame.listbox1 insert end {AtFS}
  217.   .frame2.frame.listbox1 insert end {Dependencies}
  218.   .frame2.frame.listbox1 insert end {Hypertext.txt}
  219.   .frame2.frame.listbox1 insert end {Makefile}
  220.   .frame2.frame.listbox1 insert end {Shapefile}
  221.   .frame2.frame.listbox1 insert end {Version}
  222.   .frame2.frame.listbox1 insert end {XFSymName.tcl}
  223.   .frame2.frame.listbox1 insert end {fbrowser.tcl}
  224.  
  225.  
  226. }
  227.  
  228.  
  229. # User defined procedures
  230.  
  231.  
  232. # Procedure: TkBroOpen
  233. proc TkBroOpen { fname} {
  234.   global curDir
  235.  
  236.   if {[file isdirectory $fname]} {
  237.     cd $fname
  238.     set curDir [pwd]
  239.     TkBroRefresh
  240.   } {
  241.     set thisfile [open $fname r]
  242.     [SymbolicName contentsList] delete 0 end
  243.     [SymbolicName fileName] configure -text $fname
  244.     for { set i 1 } { $i<50 } { incr i } {
  245.       [SymbolicName contentsList] insert end [ gets $thisfile ]
  246.     }
  247.     update
  248.     close $thisfile
  249.   }
  250. }
  251.  
  252.  
  253. # Procedure: TkBroRefresh
  254. proc TkBroRefresh {} {
  255.  
  256. global curDir
  257.  
  258. set list [exec ls -a]
  259. [SymbolicName dirList] delete 0 end
  260. [SymbolicName contentsList] delete 0 end
  261. [SymbolicName dirName] configure -text $curDir
  262. [SymbolicName fileName] configure -text {}
  263. foreach i $list {
  264.   [SymbolicName dirList] insert end $i
  265. }
  266. update
  267. }
  268.  
  269.  
  270. # Internal procedures
  271.  
  272.  
  273. # Procedure: Alias
  274. proc Alias { args} {
  275. # xf ignore me 7
  276. ##########
  277. # Procedure: Alias
  278. # Description: establish an alias for a procedure
  279. # Arguments: args - no argument means that a list of all aliases
  280. #                   is returned. Otherwise the first parameter is
  281. #                   the alias name, and the second parameter is
  282. #                   the procedure that is aliased.
  283. # Returns: nothing, the command that is bound to the alias or a
  284. #          list of all aliases - command pairs. 
  285. # Sideeffects: internalAliasList is updated, and the alias
  286. #              proc is inserted
  287. ##########
  288.   global internalAliasList
  289.  
  290.   if {[llength $args] == 0} {
  291.     return $internalAliasList
  292.   } {
  293.     if {[llength $args] == 1} {
  294.       set xfTmpIndex [lsearch $internalAliasList "[lindex $args 0] *"]
  295.       if {$xfTmpIndex != -1} {
  296.         return [lindex [lindex $internalAliasList $xfTmpIndex] 1]
  297.       }
  298.     } {
  299.       if {[llength $args] == 2} {
  300.         eval "proc [lindex $args 0] {args} {#xf ignore me 4
  301. return \[eval \"[lindex $args 1] \$args\"\]}"
  302.         set xfTmpIndex [lsearch $internalAliasList "[lindex $args 0] *"]
  303.         if {$xfTmpIndex != -1} {
  304.           set internalAliasList [lreplace $internalAliasList $xfTmpIndex $xfTmpIndex "[lindex $args 0] [lindex $args 1]"]
  305.         } {
  306.           lappend internalAliasList "[lindex $args 0] [lindex $args 1]"
  307.         }
  308.       } {
  309.         error "Alias: wrong number or args: $args"
  310.       }
  311.     }
  312.   }
  313. }
  314.  
  315.  
  316. # Procedure: GetSelection
  317. if {"[info procs GetSelection]" == ""} {
  318. proc GetSelection {} {
  319. # xf ignore me 7
  320. ##########
  321. # Procedure: GetSelection
  322. # Description: get current selection
  323. # Arguments: none
  324. # Returns: none
  325. # Sideeffects: none
  326. ##########
  327.  
  328.   # the save way
  329.   set xfSelection ""
  330.   catch "selection get" xfSelection
  331.   if {"$xfSelection" == "selection doesn't exist or form \"STRING\" not defined"} {
  332.     return ""
  333.   } {
  334.     return $xfSelection
  335.   }
  336. }
  337. }
  338.  
  339.  
  340. # Procedure: MenuPopupAdd
  341. if {"[info procs MenuPopupAdd]" == ""} {
  342. proc MenuPopupAdd { xfW xfButton xfMenu {xfModifier ""} {xfCanvasTag ""}} {
  343. # xf ignore me 7
  344. # the popup menu handling is from (I already gave up with popup handling :-):
  345. #
  346. # Copyright 1991,1992 by James Noble.
  347. # Everyone is granted permission to copy, modify and redistribute.
  348. # This notice must be preserved on all copies or derivates.
  349. #
  350. ##########
  351. # Procedure: MenuPopupAdd
  352. # Description: attach a popup menu to widget
  353. # Arguments: xfW - the widget
  354. #            xfButton - the button we use
  355. #            xfMenu - the menu to attach
  356. #            {xfModifier} - a optional modifier
  357. #            {xfCanvasTag} - a canvas tagOrId
  358. # Returns: none
  359. # Sideeffects: none
  360. ##########
  361.  
  362.   if {"$xfModifier" != ""} {
  363.     set xfPressModifier "$xfModifier-"
  364.     set xfMoveModifier "$xfModifier-"
  365.     set xfReleaseModifier "Any-"
  366.   } {
  367.     set xfPressModifier ""
  368.     set xfMoveModifier ""
  369.     set xfReleaseModifier ""
  370.   }
  371.  
  372.   if {"$xfCanvasTag" == ""} {
  373.     if {[catch "bind $xfW \"<${xfPressModifier}ButtonPress-$xfButton>\"                   \"$xfMenu post %X %Y\"" xfResult]} {
  374.       if {"[info commands XFProcError]" != ""} {
  375.         XFProcError "$xfResult"
  376.       } {
  377.         puts stdout "$xfResult"
  378.       }
  379.       return
  380.     }
  381.     if {[catch "bind $xfW \"<${xfMoveModifier}B$xfButton-Motion>\"                   \"MenuPopupHandle $xfMenu %W %X %Y\"" xfResult]} {
  382.       if {"[info commands XFProcError]" != ""} {
  383.         XFProcError "$xfResult"
  384.       } {
  385.         puts stdout "$xfResult"
  386.       }
  387.       return
  388.     }
  389.     # we need these to counteract the effects of passive grabs :-(
  390.     if {[catch "bind $xfW \"<${xfReleaseModifier}ButtonRelease-$xfButton>\"                   \"$xfMenu invoke active; $xfMenu unpost\"" xfResult]} {
  391.       if {"[info commands XFProcError]" != ""} {
  392.         XFProcError "$xfResult"
  393.       } {
  394.         puts stdout "$xfResult"
  395.       }
  396.       return
  397.     }
  398.   } {
  399.     if {[catch "$xfW bind $xfCanvasTag \"<${xfPressModifier}ButtonPress-$xfButton>\"                   \"$xfMenu post %X %Y\"" xfResult]} {
  400.       if {"[info commands XFProcError]" != ""} {
  401.         XFProcError "$xfResult"
  402.       } {
  403.         puts stdout "$xfResult"
  404.       }
  405.       return
  406.     }
  407.     if {[catch "$xfW bind $xfCanvasTag \"<${xfMoveModifier}B$xfButton-Motion>\"                   \"MenuPopupHandle $xfMenu %W %X %Y\"" xfResult]} {
  408.       if {"[info commands XFProcError]" != ""} {
  409.         XFProcError "$xfResult"
  410.       } {
  411.         puts stdout "$xfResult"
  412.       }
  413.       return
  414.     }
  415.     # we need these to counteract the effects of passive grabs :-(
  416.     if {[catch "$xfW bind $xfCanvasTag \"<${xfReleaseModifier}ButtonRelease-$xfButton>\"                   \"$xfMenu invoke active; $xfMenu unpost\"" xfResult]} {
  417.       if {"[info commands XFProcError]" != ""} {
  418.         XFProcError "$xfResult"
  419.       } {
  420.         puts stdout "$xfResult"
  421.       }
  422.       return
  423.     }
  424.   }
  425. }
  426. }
  427.  
  428.  
  429. # Procedure: MenuPopupHandle
  430. if {"[info procs MenuPopupHandle]" == ""} {
  431. proc MenuPopupHandle { xfMenu xfW xfX xfY} {
  432. # xf ignore me 7
  433. ##########
  434. # Procedure: MenuPopupHandle
  435. # Description: handle the popup menus
  436. # Arguments: xfMenu - the menu to attach
  437. #            xfW - the widget
  438. #            xfX - the root x coordinate
  439. #            xfY - the root x coordinate
  440. # Returns: none
  441. # Sideeffects: none
  442. ##########
  443.  
  444.   if {"[info commands $xfMenu]" != "" && [winfo ismapped $xfMenu]} {
  445.     set xfPopMinX [winfo rootx $xfMenu]
  446.     set xfPopMaxX [expr $xfPopMinX+[winfo width $xfMenu]]
  447.     if {($xfX >= $xfPopMinX) &&  ($xfX <= $xfPopMaxX)} {
  448.       $xfMenu activate @[expr $xfY-[winfo rooty $xfMenu]]
  449.     } {
  450.       $xfMenu activate none
  451.     }
  452.   }
  453. }
  454. }
  455.  
  456.  
  457. # Procedure: NoFunction
  458. if {"[info procs NoFunction]" == ""} {
  459. proc NoFunction { args} {
  460. # xf ignore me 7
  461. ##########
  462. # Procedure: NoFunction
  463. # Description: do nothing (especially with scales and scrollbars)
  464. # Arguments: args - a number of ignored parameters
  465. # Returns: none
  466. # Sideeffects: none
  467. ##########
  468. }
  469. }
  470.  
  471.  
  472. # Procedure: SN
  473. if {"[info procs SN]" == ""} {
  474. proc SN { {xfName ""}} {
  475. # xf ignore me 7
  476. ##########
  477. # Procedure: SN
  478. # Description: map a symbolic name to the widget path
  479. # Arguments: xfName
  480. # Returns: the symbolic name
  481. # Sideeffects: none
  482. ##########
  483.  
  484.   SymbolicName $xfName
  485. }
  486. }
  487.  
  488.  
  489. # Procedure: SymbolicName
  490. if {"[info procs SymbolicName]" == ""} {
  491. proc SymbolicName { {xfName ""}} {
  492. # xf ignore me 7
  493. ##########
  494. # Procedure: SymbolicName
  495. # Description: map a symbolic name to the widget path
  496. # Arguments: xfName
  497. # Returns: the symbolic name
  498. # Sideeffects: none
  499. ##########
  500.  
  501.   global symbolicName
  502.  
  503.   if {"$xfName" != ""} {
  504.     set xfArrayName ""
  505.     append xfArrayName symbolicName ( $xfName )
  506.     if {![catch "set \"$xfArrayName\"" xfValue]} {
  507.       return $xfValue
  508.     } {
  509.       if {"[info commands XFProcError]" != ""} {
  510.         XFProcError "Unknown symbolic name:\n$xfName"
  511.       } {
  512.         puts stderr "XF error: unknown symbolic name:\n$xfName"
  513.       }
  514.     }
  515.   }
  516.   return ""
  517. }
  518. }
  519.  
  520.  
  521. # Procedure: Unalias
  522. proc Unalias { aliasName} {
  523. # xf ignore me 7
  524. ##########
  525. # Procedure: Unalias
  526. # Description: remove an alias for a procedure
  527. # Arguments: aliasName - the alias name to remove
  528. # Returns: none
  529. # Sideeffects: internalAliasList is updated, and the alias
  530. #              proc is removed
  531. ##########
  532.   global internalAliasList
  533.  
  534.   set xfIndex [lsearch $internalAliasList "$aliasName *"]
  535.   if {$xfIndex != -1} {
  536.     rename $aliasName ""
  537.     set internalAliasList [lreplace $internalAliasList $xfIndex $xfIndex]
  538.   }
  539. }
  540.  
  541.  
  542.  
  543. # application parsing procedure
  544. proc XFLocalParseAppDefs {xfAppDefFile} {
  545.   global xfAppDefaults
  546.  
  547.   # basically from: Michael Moore
  548.   if {[file exists $xfAppDefFile] &&
  549.       [file readable $xfAppDefFile] &&
  550.       "[file type $xfAppDefFile]" == "link"} {
  551.     catch "file type $xfAppDefFile" xfType
  552.     while {"$xfType" == "link"} {
  553.       if {[catch "file readlink $xfAppDefFile" xfAppDefFile]} {
  554.         return
  555.       }
  556.       catch "file type $xfAppDefFile" xfType
  557.     }
  558.   }
  559.   if {!("$xfAppDefFile" != "" &&
  560.         [file exists $xfAppDefFile] &&
  561.         [file readable $xfAppDefFile] &&
  562.         "[file type $xfAppDefFile]" == "file")} {
  563.     return
  564.   }
  565.   if {![catch "open $xfAppDefFile r" xfResult]} {
  566.     while {[gets $xfResult line] != -1} {
  567.       # backup indicates how far to backup.  It applies to the
  568.       # situation where a resource name ends in . and when it
  569.       # ends in *.  In the second case you want to keep the *
  570.       # in the widget name for pattern matching, but you want
  571.       # to get rid of the . if it is the end of the name. 
  572.       set backup -2  
  573.       set line [string trim $line]
  574.       if {[string index $line 0] == "#" || "$line" == ""} {
  575.         # skip comments and empty lines
  576.         continue
  577.       }
  578.       set list [split $line ":"]
  579.       set resource [string trim [lindex $list 0]]
  580.       set i [string last "." $resource]
  581.       set j [string last "*" $resource]
  582.       if {$j > $i} { 
  583.         set i $j
  584.         set backup -1
  585.       }
  586.       incr i
  587.       set name [string range $resource $i end]
  588.       incr i $backup
  589.       set widname [string range $resource 0 $i]
  590.       set value [string trim [lindex $list 1]]
  591.       if {"$widname" != "" && "$widname" != "*"} {
  592.         # insert the widget and resourcename to the application
  593.         # defaults list.
  594.         set xfAppDefaults($widname:[string tolower $name]) $value
  595.       }
  596.     }
  597.   }
  598. }
  599.  
  600. # application loading procedure
  601. proc XFLocalLoadAppDefs {xfClasses {xfPriority "startupFile"} {xfAppDefFile ""}} {
  602.   global env
  603.  
  604.   if {"$xfAppDefFile" == ""} {
  605.     set xfFileList ""
  606.     if {[info exists env(XUSERFILESEARCHPATH)]} {
  607.       append xfFileList [split $env(XUSERFILESEARCHPATH) :]
  608.     }
  609.     if {[info exists env(XAPPLRESDIR)]} {
  610.       append xfFileList [split $env(XAPPLRESDIR) :]
  611.     }
  612.     if {[info exists env(XFILESEARCHPATH)]} {
  613.       append xfFileList [split $env(XFILESEARCHPATH) :]
  614.     }
  615.     append xfFileList " /usr/lib/X11/app-defaults"
  616.     append xfFileList " /usr/X11/lib/X11/app-defaults"
  617.  
  618.     foreach xfCounter1 $xfClasses {
  619.       foreach xfCounter2 $xfFileList {
  620.         set xfPathName $xfCounter2
  621.         if {[regsub -all "%N" "$xfPathName" "$xfCounter1" xfResult]} {
  622.           set xfPathName $xfResult
  623.         }
  624.         if {[regsub -all "%T" "$xfPathName" "app-defaults" xfResult]} {
  625.           set xfPathName $xfResult
  626.         }
  627.         if {[regsub -all "%S" "$xfPathName" "" xfResult]} {
  628.           set xfPathName $xfResult
  629.         }
  630.         if {[regsub -all "%C" "$xfPathName" "" xfResult]} {
  631.           set xfPathName $xfResult
  632.         }
  633.         if {[file exists $xfPathName] &&
  634.             [file readable $xfPathName] &&
  635.             ("[file type $xfPathName]" == "file" ||
  636.              "[file type $xfPathName]" == "link")} {
  637.           catch "option readfile $xfPathName $xfPriority"
  638.           if {"[info commands XFParseAppDefs]" != ""} {
  639.             XFParseAppDefs $xfPathName
  640.           } {
  641.             if {"[info commands XFLocalParseAppDefs]" != ""} {
  642.               XFLocalParseAppDefs $xfPathName
  643.             }
  644.           }
  645.         } {
  646.           if {[file exists $xfCounter2/$xfCounter1] &&
  647.               [file readable $xfCounter2/$xfCounter1] &&
  648.               ("[file type $xfCounter2/$xfCounter1]" == "file" ||
  649.                "[file type $xfCounter2/$xfCounter1]" == "link")} {
  650.             catch "option readfile $xfCounter2/$xfCounter1 $xfPriority"
  651.             if {"[info commands XFParseAppDefs]" != ""} {
  652.               XFParseAppDefs $xfCounter2/$xfCounter1
  653.             } {
  654.               if {"[info commands XFLocalParseAppDefs]" != ""} {
  655.                 XFLocalParseAppDefs $xfCounter2/$xfCounter1
  656.               }
  657.             }
  658.           }
  659.         }
  660.       }
  661.     }
  662.   } {
  663.     # load a specific application defaults file
  664.     if {[file exists $xfAppDefFile] &&
  665.         [file readable $xfAppDefFile] &&
  666.         ("[file type $xfAppDefFile]" == "file" ||
  667.          "[file type $xfAppDefFile]" == "link")} {
  668.       catch "option readfile $xfAppDefFile $xfPriority"
  669.       if {"[info commands XFParseAppDefs]" != ""} {
  670.         XFParseAppDefs $xfAppDefFile
  671.       } {
  672.         if {"[info commands XFLocalParseAppDefs]" != ""} {
  673.           XFLocalParseAppDefs $xfAppDefFile
  674.         }
  675.       }
  676.     }
  677.   }
  678. }
  679.  
  680. # application setting procedure
  681. proc XFLocalSetAppDefs {{xfWidgetPath "."}} {
  682.   global xfAppDefaults
  683.  
  684.   if {![info exists xfAppDefaults]} {
  685.     return
  686.   }
  687.   foreach xfCounter [array names xfAppDefaults] {
  688.     if {[string match "${xfWidgetPath}*" $xfCounter]} {
  689.       set widname [string range $xfCounter 0 [expr [string first : $xfCounter]-1]]
  690.       set name [string range $xfCounter [expr [string first : $xfCounter]+1] end]
  691.       # Now lets see how many tcl commands match the name
  692.       # pattern specified.
  693.       set widlist [info command $widname]
  694.       if {"$widlist" != ""} {
  695.         foreach widget $widlist {
  696.           # make sure this command is a widget.
  697.           if {![catch "winfo id $widget"]} {
  698.             catch "$widget configure -[string tolower $name] $xfAppDefaults($xfCounter)" 
  699.           }
  700.         }
  701.       }
  702.     }
  703.   }
  704. }
  705.  
  706.  
  707.  
  708. # end source
  709. proc EndSrc {} {
  710. global curDir
  711.  
  712. set curDir [pwd]
  713. TkBroRefresh
  714. }
  715.  
  716. # prepare auto loading
  717. global auto_path
  718. global tk_library
  719. global xfLoadPath
  720. set auto_path "[split $xfLoadPath :] $tk_library [info library]"
  721.  
  722. # initialize global variables
  723. proc InitGlobals {} {
  724.   global {curDir}
  725.   set {curDir} {/home/garfield/development/xf/demos}
  726.  
  727.   # please don't modify the following
  728.   # variables. They are needed by xf.
  729.   global {autoLoadList}
  730.   set {autoLoadList(fbrowser.tcl)} {0}
  731.   set {autoLoadList(main.tcl)} {0}
  732.   global {internalAliasList}
  733.   set {internalAliasList} {}
  734.   global {moduleList}
  735.   set {moduleList(fbrowser.tcl)} { TkBroOpen TkBroRefresh Alias GetSelection MenuPopupAdd MenuPopupHandle NoFunction SN SymbolicName Unalias .}
  736.   global {preloadList}
  737.   set {preloadList(xfInternal)} {}
  738.   global {symbolicName}
  739.   set {symbolicName(contentsList)} {.frame2.frame6.listbox1}
  740.   set {symbolicName(dirList)} {.frame2.frame.listbox1}
  741.   set {symbolicName(dirName)} {.frame1.label4}
  742.   set {symbolicName(fileName)} {.frame1.label5}
  743.   set {symbolicName(root)} {.}
  744.   global {xfWmSetPosition}
  745.   set {xfWmSetPosition} {}
  746.   global {xfWmSetSize}
  747.   set {xfWmSetSize} {.}
  748.   global {xfAppDefToplevels}
  749.   set {xfAppDefToplevels} {}
  750. }
  751.  
  752. # initialize global variables
  753. InitGlobals
  754.  
  755. # display/remove toplevel windows.
  756. ShowWindow.
  757.  
  758. # load default bindings.
  759. if {[info exists env(XF_BIND_FILE)] &&
  760.     "[info procs XFShowHelp]" == ""} {
  761.   source $env(XF_BIND_FILE)
  762. }
  763.  
  764. # parse and apply application defaults.
  765. XFLocalLoadAppDefs Fbrowser
  766. XFLocalSetAppDefs
  767.  
  768. # end source
  769. EndSrc
  770.  
  771. # eof
  772. #
  773.  
  774.